﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jbe.Composite.Extensions;
using Microsoft.Practices.Composite.Regions;
using Jbe.TestSuite.Infrastructure.Interface;
using Jbe.TestSuite.TestDevices.Interface;
using Jbe.TestSuite.TestDevices.FunctionGenerator.Driver.Properties;

namespace Jbe.TestSuite.TestDevices.FunctionGenerator.Driver.Applications
{
    internal class ModuleController
    {
        private readonly IApplicationContainer container;
        private readonly IRegionManager regionManager;
        private readonly IUIElementCreationService uiElementCreationService;


        public ModuleController(IApplicationContainer container, IRegionManager regionManager, IUIElementCreationService uiElementCreationService)
        {
            this.container = container;
            this.regionManager = regionManager;
            this.uiElementCreationService = uiElementCreationService;
        }


        public void Initialize()
        {
            IMenuItem newFunctionGen = uiElementCreationService.CreateMenuItem(Resources.FunctionGenerator);
            newFunctionGen.Click += NewFunctionGenClick;
            regionManager.Regions[TestDeviceManagerRegionNames.NewDeviceMenuItems].Add(newFunctionGen);
        }

        private void NewFunctionGenClick(object sender, EventArgs e)
        {
            DeviceController controller = container.Resolve<DeviceController>();
            controller.Run();
        }
    }
}
